Applications launched using D-Bus activation will have a returned PID of
0, which systemd interprets as moving the requesting process to a new
scope, causing GNOME Shell to be moved to another scope. Fix this by not
creating a systemd scope when PID is 0.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2305>
if (!g_variant_lookup (platform_data, "pid", "i", &pid))
return;
+ /* If pid == 0 the application was launched through D-Bus
+ * activation, therefore it's already in its own unit */
+ if (pid == 0)
+ return;
+
app_name = g_app_info_get_id (info);
if (app_name == NULL)
app_name = g_app_info_get_executable (info);